<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>小工具</title>
    <link href="<?= base_url( 'res/web/js/bootstrap-3.3.5/css/bootstrap.css' ) ?>" rel="stylesheet">
    <link href="<?= base_url( 'res/web/css/tip-darkgray/tip-darkgray.css' ); ?>" rel="stylesheet">
    <link href="<?= base_url( 'res/web/css/jquery.dataTables.min.css' ); ?>" rel="stylesheet">
    <script src="<?= base_url( 'res/web/js/jquery-1.11.1.min.js' ) ?>"></script>
    <script src="<?= base_url( 'res/web/js/bootstrap.min.js' ) ?>"></script>
    <script src="<?= base_url( 'res/web/js/json2.js' ) ?>"></script>
    <script src="<?= base_url( 'res/web/js/jquery.poshytip.js' ) ?>"></script>
    <script src="<?= base_url( 'res/web/js/jquery.dataTables.min.js' ) ?>"></script>
    <script src="<?= base_url( 'res/web/src/bootstrap-table.js' ) ?>"></script>

</head>

<body>
<div class="container">
    <div class="row content">
        <div class="panel panel-default">
            <div class="panel-heading">
                填写学生基本信息&nbsp;&nbsp;>&nbsp;&nbsp;选择奖项、论文和专利&nbsp;&nbsp;>&nbsp;&nbsp;选择报考地区&nbsp;&nbsp;>&nbsp;&nbsp;<strong>查看报告结果</strong>
                <span id="btn" class="btn btn-default btn-xs" style="float:right"
                      role="button">重新测试</span>
            </div>
            <div class="panel-body">
                <dl class="dl-horizontal">
                    <dt>报告结果：</dt>
                    <dd class="stu-place">
                        <label>
                            <input type="radio" checked name="baogao_style" value="xiaoshou" aria-label="">销售用
                        </label>
                        <label style="margin-left: 20%;">
                            <input type="radio" name="baogao_style" value="guwen" aria-label="">顾问用
                        </label>
                    </dd>
                </dl>
                <dl class="dl-horizontal">
                    <dt style="padding-top: 10px">冲刺学校：</dt>
                    <dd>
                        <table class="chongci-table" class="table" width="100%">
                            <thead>
                            <tr>
                                <th data-field="school_name">学校</th>
                                <th data-field="school_level">定位</th>
                                <th data-field="province_name">所在地</th>
                                <th data-field="specialty_name">专业1</th>
                                <th data-field="specialty_name1">专业2</th>
                                <th data-field="specialty_name">专业3</th>
                                <th data-field="major_list">全部专业</th>
                            </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                    </dd>
                </dl>
                <dl class="dl-horizontal">
                    <dt style="padding-top: 10px">推荐学校：</dt>
                    <dd>
                        <table class="tuijian-table" class="table" width="100%">
                            <thead>
                            <tr>
                                <th data-field="school_name">学校</th>
                                <th data-field="school_level">定位</th>
                                <th data-field="province_name">所在地</th>
                                <th data-field="specialty_name">专业1</th>
                                <th data-field="specialty_name1">专业2</th>
                                <th data-field="specialty_name">专业3</th>
                                <th data-field="major_list">全部专业</th>
                            </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                    </dd>
                </dl>
                <dl class="dl-horizontal">
                    <dt style="padding-top: 10px">保底学校：</dt>
                    <dd>
                        <table class="baodi-table" class="table" width="100%">
                            <thead>
                            <tr>
                                <th data-field="school_name">学校</th>
                                <th data-field="school_level">定位</th>
                                <th data-field="province_name">所在地</th>
                                <th data-field="specialty_name">专业1</th>
                                <th data-field="specialty_name1">专业2</th>
                                <th data-field="specialty_name">专业3</th>
                                <th data-field="major_list">全部专业</th>
                            </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                        <!--<table class="table table-striped">
                            <thead>
                            <tr>
                                <th>学校</th>
                                <th>定位</th>
                                <th>所在地</th>
                                <th>专业1</th>
                                <th>专业2</th>
                                <th>专业3</th>
                                <th>全部专业</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td class="select-school-name">北京大学</td>
                                <td class="select-school-dingwei">211</td>
                                <td class="select-school-place">北京</td>
                                <td>物理</td>
                                <td>化学</td>
                                <td>数学</td>
                                <td><span class="look-more">查看</span></td>
                            </tr>
                            <tr>
                                <td class="select-school-name">清华大学</td>
                                <td class="select-school-dingwei">211</td>
                                <td class="select-school-place">北京</td>
                                <td>物理</td>
                                <td>化学</td>
                                <td>数学</td>
                                <td><span class="look-more">查看</span></td>
                            </tr>
                            </tbody>
                        </table>-->
                    </dd>
                </dl>
                <dl class="dl-horizontal">
                    <dt style="padding-top: 10px">保底学校：</dt>
                    <dd>
                        <table id="test-table" class="table  table-striped display" width="100%">
                            <thead>
                            <tr>
                                <th>学校</th>
                                <th>定位</th>
                                <th>所在地</th>
                                <th>专业1</th>
                                <th>专业2</th>
                                <th>专业3</th>
                                <th>全部专业</th>
                            </tr>
                            </thead>
                        </table>
                    </dd>
                </dl>
            </div>
        </div>
    </div>
    <button name="btnType">eeeeee</button>
</div>
<script>
    $( function() {
        $( "#btn" ).click( function() {
            getData();
        } )
        var table;
        $("button[name='btnType']").bind("click", function () { //按钮 触发table重新请求服务器

            //table.fnDraw();
            getData();
        });
        function getData() {
            table=$( '#test-table' ).dataTable( {
                bDestroy     : true,
                "ajax"      : {

                    "url" : "<?=base_url('welcome/getTestBaodiSchool');?>",
                    "data": function( d ) {
                        //添加额外的参数传给服务器
                        d.score = 10;
                        d.awards_code=101;
                        d.college_place=110000;
                    },
                    "dataType": 'json',
                    //"type": "POST",
                    /*"success": function(data){
                       console.info(data)

                        tmp_data=data.data;
                        for(var i in tmp_data){
                            console.info(i);
                        }
                        return data;
                    }*/
                },

                "columns"   : [

                    { "data": "school_name" },
                    { "data": "school_level" },
                    { "data": "specialty_name0" },
                    { "data": "specialty_name1" },
                    { "data": "specialty_name0" },
                    { "data": "major_list" }
                ],
                "fnServerParams": function (aoData) {  //查询条件
                    /*aoData.push(
                        { "name": "EventNO" },
                        { "name": "EventContent" },
                    );*/
                    aoData.test=123;
                },
                "columnDefs": [
                    // 将name列变为红色
                    {
                        "targets": [0], // 目标列位置，下标从0开始
                        "data": "option_ip", // 数据列名
                        "render": function(data, type, row) { // 返回自定义内容
                            return "<span style='color:red;'>" + data+type + "</span>";
                        }
                    },
                    // 增加一列，包括删除和修改，同时将需要传递的数据传递到链接中
                    {
                        "targets": [6], // 目标列位置，下标从0开始
                        "data": "option_time", // 数据列名
                        "render": function(data, type, row) { // 返回自定义内容
                            return "<a href=‘/delete?name=" + data + "‘>删除</a>&nbsp;<a href=‘/update?name=" + data + "‘>更新</a>";
                        }

                    },{
                        "targets": [1], // 目标列位置，下标从0开始
                        //"data": "specialty_name", // 数据列名
                        "render": function(data, type, row) { // 返回自定义内容
                            console.info(data);
                            console.info(type);
                            console.info(row);
                            return row.major_list.split(',')[0];
                        }
                    }
                ],
                "aLengthMenu": [[10, 25, 50, -1], [2, 25, 50, "All"]],

                "language"  : {
                    "sProcessing"    : "处理中...",
                    "sLengthMenu"    : "显示 _MENU_ 项结果",
                    "sZeroRecords"   : "没有匹配结果",
                    "sInfo"          : "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                    "sInfoEmpty"     : "显示第 0 至 0 项结果，共 0 项",
                    "sInfoFiltered"  : "(由 _MAX_ 项结果过滤)",
                    "sInfoPostFix"   : "",
                    "sSearch"        : "搜索:",
                    "sUrl"           : "",
                    "sEmptyTable"    : "表中数据为空",
                    "sLoadingRecords": "载入中...",
                    "sInfoThousands" : ",",
                    "oPaginate"      : {
                        "sFirst"   : "首页",
                        "sPrevious": "上页",
                        "sNext"    : "下页",
                        "sLast"    : "末页"
                    },
                    "oAria"          : {
                        "sSortAscending" : ": 以升序排列此列",
                        "sSortDescending": ": 以降序排列此列"
                    }
                },
                //还有一个常用的是rowCallback，当创建了行，但还未绘制到屏幕上的时候调用，通常用于改变行的class风格。比如为列为IP的这一行加个超链接，代码接着上面的：
                "rowCallback": function(row, data) { //data是后端返回的数据

                    var list=data;
                    var tt=list.major_list.split(',');
                    $("td:eq(3)", row).html("<a target='_blank' href=http://" + data.school_name + ">" + data.option_ip + "</a>");
                    /*if(data.option_ip) {
                        $("td:eq(3)", row).html("<a target='_blank' href=http://" + data.option_ip + ">" + data.option_ip + "</a>");
                    }*/
                },

            } );
        }

    } )
</script>
</body>
</html>